!function() {
    
    // 获得基础JIPIN对象
    var JIPIN = window.__NS__JIPIN;
    if(!JIPIN) { return; }
    var $ = JIPIN.$;
    
    JIPIN._fixImage = JIPIN.fixImage;
    JIPIN._refixImage = JIPIN.refixImage;
    
    JIPIN._getSitePicDesc = JIPIN.getSitePicDesc;
    JIPIN.getSitePicDesc = function(targetPic) {
        if(isWaterfallPic(targetPic)) {
            var listBox = targetPic.closest('div.list-ibox');
            if(listBox.find('em.money').length && listBox.find('a.J_ItemDesc').length) {
                return $('<div>'+listBox.find('a.J_ItemDesc').data('itemDesc')+'</div>').text() + ' ￥' + $.trim(listBox.find('em.money').first().text());
            } else {
                return JIPIN._getSitePicDesc(targetPic);
            }
            
        } else {
            return JIPIN._getSitePicDesc(targetPic);
        }
    };
    
    JIPIN.getSourceURL = function(targetPic) {
        var url = document.location.href;
        if(isWaterfallPic(targetPic)) {
            url = targetPic.parent().get(0).href; 
        }
        return url;
    };
    
    JIPIN.fixImage = function(image, callback) {
        if(isWaterfallPic(image)) {
            callback(image);
        } else {
            this._fixImage(image, callback);
        }
    };
    
    JIPIN.refixImage = function(image, callback) {
        if(isWaterfallPic(image)) {
            callback(image);
        } else {
            this._refixImage(image, callback);
        }
    };
    
    function isWaterfallPic(pic) {
        return $(pic).parent().parent().parent().is('div.list-ibox');
    }
    
}();